home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c++ / 1023 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  1.7 KB

  1. From: Sean A Corfield <sean@corf.demon.co.uk>
  2. Message-ID: <AD9145EF96685D5D@corf.demon.co.uk>
  3. X-Original-Date: Wed, 10 Apr 1996 11:03:11 +0100
  4. Path: in1.uu.net!bounce-back
  5. Date: 10 Apr 96 11:21:32 GMT
  6. Approved: fjh@cs.mu.oz.au
  7. Newsgroups: comp.std.c++
  8. Subject: Re: C++ syntactic trap
  9. Organization: OCS
  10. References: <4k3q4p$lkd@syn.cs.cornell.edu>
  11. X-Auth: PGPMoose V1.1 PGP comp.std.c++
  12.     iQBFAgUBMWuZwOEDnX0m9pzZAQGjawF/f50Mn75KtT+U/wbXM3rsvrkm3jA7qV0j
  13.     y5NqDLsWXCJeoknQHWqLincoASjeGLrJ
  14.     =SiZF
  15.  
  16. In article <4k3q4p$lkd@syn.cs.cornell.edu>,
  17. vavasis@CS.Cornell.EDU (Stephen Vavasis) wrote:
  18.  
  19. |> The troubling thing about this trap is that none of the unix
  20. |> compilers I tried (gcc-2.7.2, Sun SC3.0.1, HP-UX cfront 3.0.3) issued
  21. |> a warning about the mistake, even on the highest warning level.  Only
  22. |> Visual C++4.0 observed that there might be a problem.  Here is an
  23. |> example of the trap. 
  24. ...
  25. |>   char* a = new char(sz + 1); // bug is here, but syntax is legal.
  26.  
  27. Perhaps you should try one of the C++ lints? There are many, many areas
  28. where the (draft) standard allows constructs of dubious value but the
  29. committee have always been careful not to remove a construct solely on the
  30. grounds that programmers might shoot themselves in the foot.
  31.  
  32. Sean A Corfield
  33. Object Consultancy Services
  34. C++ - Beyond the ARM - http://nw.demon.co.uk/ocsltd/c++/
  35. ---
  36. [ comp.std.c++ is moderated.  To submit articles: try just posting with      ]
  37. [ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu         ]
  38. [ FAQ:      http://reality.sgi.com/employees/austern_mti/std-c++/faq.html    ]
  39. [ Policy:   http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
  40. [ Comments? mailto:std-c++-request@ncar.ucar.edu                             ]
  41.